package com.Data;


import android.os.AsyncTask;
import com.SoapClasses.SoapPost_Follows;


public class Followers extends AsyncTask<Integer, String, User[]> {

    public final static int ACTION_GET = 0;

    public final static int ACTION_SEARCH = 1;

    private onGetFollowersCompleted callbackGetFollowers;

    private int ID;

    private String seach;

    public interface onGetFollowersCompleted {

        void Completed(User[] result);
    }

    public Followers(int iD) {

        super();
        ID = iD;
    }

    public Followers(String searchFor) {

        this.seach = searchFor;
    }

    public onGetFollowersCompleted getCallbackGetFollowers() {

        return callbackGetFollowers;
    }

    public void setCallbackGetFollowers(onGetFollowersCompleted callbackGetFollowers) {

        this.callbackGetFollowers = callbackGetFollowers;
    }

    @Override
    protected User[] doInBackground(Integer... action) {

        switch (action[0]) {
            case ACTION_GET:
                return new SoapPost_Follows().getFriends(ID);
            case ACTION_SEARCH:
                return new SoapPost_Follows().findFollowers(this.seach);
            default:
                return null;
        }

    }

    @Override
    protected void onPostExecute(User[] result) {

        if (callbackGetFollowers != null)
            callbackGetFollowers.Completed(result);
    }

}
